#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QPushButton* button1 = new QPushButton("按钮1");
    QPushButton* button2 = new QPushButton("按钮2");
    QPushButton* button3 = new QPushButton("按钮3");
    QPushButton* button4 = new QPushButton("按钮4");
    QPushButton* button5 = new QPushButton("按钮5");
    QPushButton* button6 = new QPushButton("按钮6");

    button1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    button2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    button3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    button4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    button5->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    button6->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


    QGridLayout* layout = new QGridLayout();
    layout->addWidget(button1, 0, 0);
    layout->addWidget(button2, 0, 1);
    layout->addWidget(button3, 1, 0);
    layout->addWidget(button4, 1, 1);
    layout->addWidget(button5, 3, 3);
    layout->addWidget(button6, 4, 4);
    layout->setColumnStretch(0, 5);
    layout->setColumnStretch(1, 0);
    layout->setColumnStretch(3, 3);
    layout->setRowStretch(0, 10);
    layout->setRowStretch(1, 1);

    // QHBoxLayout* layout2 = new QHBoxLayout();
    // QVBoxLayout* layout = new QVBoxLayout();
    // layout->addWidget(button1);
    // layout->addWidget(button2);
    // layout->addLayout(layout2);
    // layout2->addWidget(button3);
    // layout2->addWidget(button4);
    // layout2->addWidget(button5);

    // QVBoxLayout* layout = new QVBoxLayout();
    // layout->addWidget(button1);
    // layout->addWidget(button2);
    // layout->addWidget(button3);

    this->setLayout(layout);
}

Widget::~Widget()
{
    delete ui;
}
